Skip to content

fix(github-backup): shape-validate config, bws output and conversion response in app_setup (#6849) - #8690

Merged
dezren39 merged 1 commit into
mainfrom
queue/11070-6849-app-setup-shape
Nov 11, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/11070-6849-app-setup-shape

Conversation

@dezren39

@dezren39 dezren39 commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Fixes #6849.

Problem

app_setup.py parsed every trust-boundary value unguarded: a wrong-shape config.json crashed every subcommand at import (KeyError/TypeError from the import-time CFG["app"]["bitwarden_secret_names"] indexing), _project_id/bws_get never checked the bws return code (a bws failure surfaced as a false "no projects" claim or a raw JSONDecodeError), and cmd_convert stored credentials one at a time from an unvalidated conversion response — a missing pem crashed after 3 of 4 secrets were already stored, leaving a partial credential set.

Fix

  • ghb_common.load_config now validates via new validate_config (the github-backup(fetch): a valid-JSON but wrong-shape plan/state entry crashes the whole daily fetch — one poison entry in plan.json or state.json wedges every repo, every day #6637 named-problem contract): top-level object, app object with non-empty string name, events list of strings, bitwarden_secret_names string->non-empty-string object containing the five names app_setup stores under, and worker.webhook_path non-empty string. Violations raise a field-naming ValueError; app_setup catches it at import and exits 2 with a clean stderr diagnostic for every subcommand.
  • Shared _bws_json checks the subprocess return code (reports the bws failure with its stderr excerpt) and parseability; _bws_list, _project_id, and bws_get additionally validate the parsed shape (list of objects with string id/key; object with string value).
  • cmd_convert runs validate_conversion (integer id; non-empty string client_id/client_secret/pem/slug) before the first bws_set — a bad response stores nothing.
  • cmd_install_report runs validate_installations (integer id, account.login string) before indexing.

Tests

Oracle: the #6849 probe table. New tests/test_app_setup_shape.py (14 tests): wrong-shape config cases name the field, real-config control passes, import with a wrong-shape config exits 2 with no traceback, bws error-object / non-object-list / failed-call cases report the bws failure or the shape, partial conversion response stores nothing, full conversion stores all four values in order, installations shape validated. Whole infra/github-backup/tests/ suite green (14 files).

Queue task 11070, lane code-c.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…response in app_setup (#6849)

load_config now validates the config shape the tools index (app.name/events/bitwarden_secret_names with the app_setup names, worker.webhook_path) and raises a field-naming ValueError; app_setup turns that into a clean stderr diagnostic + exit 2 at import for every subcommand. _bws_list/_project_id/bws_get check return codes (reporting the bws failure) and parsed shapes via a shared _bws_json. cmd_convert validates the full conversion response (id/client_id/client_secret/pem/slug) before the first bws_set, so a bad response stores nothing. install-report validates the installations payload before indexing. New tests test_app_setup_shape.py (14) cover the probe cases; full github-backup suite green.
@dezren39
dezren39 requested a review from a team as a code owner November 11, 2026 13:55
@coderabbitai

coderabbitai Bot commented Nov 11, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 13 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 058dbc1c-ccb9-4bb2-b5a8-0e3849518969
Commits

Reviewing files that changed from the base of the PR and between 92004d6 and b1c5db7.

Files selected for processing: 3

  • infra/github-backup/bin/app_setup.py
  • infra/github-backup/bin/ghb_common.py
  • infra/github-backup/tests/test_app_setup_shape.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T13:58:22.756982Z b1c5db7 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@dezren39

Copy link
Copy Markdown
Member Author

@codex review

New PR for #6849: shape validation for config (validate_config in ghb_common), bws readers (return-code + shape via _bws_json), conversion response validated before any bws_set, and installations payload validated before indexing. Please review head b1c5db7. (Queue worker lane code-c, task 11070.)

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: b1c5db7f22

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@dezren39
dezren39 merged commit cf86bdf into main Nov 11, 2026
1 of 14 checks passed
@dezren39
dezren39 deleted the queue/11070-6849-app-setup-shape branch November 11, 2026 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant